// 节流函数
export const throttle = (fn, time) => {
  let falg = null
  time = time || 1000
  return function () {
    if (falg) return
    falg = setTimeout(() => {
      falg = null
    }, time)
    fn.call(this)
  }
}

// 防抖
export const debounce = (fn, time) => {
  time = time || 200
  // 定时器
  let timer = null
  return function (...args) {
    if (timer) {
      clearTimeout(timer)
    }
    timer = setTimeout(function () {
      timer = null
      fn.apply(this, args)
    }, time)
  }
}

// 处理大额数字
export const bigNumber = (value) => {
  if (typeof value === 'string') {
    value = Number(value)
  }
  if (value < 10000) {
    return value
  } else {
    return (value / 10000).toFixed(2)
  }
}
